#ifndef RAY_TRACE_PRO_DEBUG_H
#define RAY_TRACE_PRO_DEBUG_H

#include <Windows.h>
#include <stdio.h>

namespace RayTracePro
{
	class DebugTimming
	{
	private:
		static LARGE_INTEGER freq, counter;
		static LARGE_INTEGER ticks[256];
		static LARGE_INTEGER counters[256];
	public:
		static inline void Start(const char * str)
		{
			QueryPerformanceFrequency(&freq);
			QueryPerformanceCounter(&counter);
			printf(str);
		}

		static inline void End()
		{
			LARGE_INTEGER counter2;
			QueryPerformanceCounter(&counter2);
			double time = (counter2.QuadPart - counter.QuadPart)/(double)freq.QuadPart;
			printf("%.3fs\n", time);
		}
		static inline void StartCounter(int id)
		{
			QueryPerformanceCounter(&counters[id]);
		}
		static inline void StopCounter(int id)
		{
			LARGE_INTEGER counter2;
			QueryPerformanceCounter(&counter2);
			ticks[id].QuadPart += counter2.QuadPart-counters[id].QuadPart;
		}
		static inline void ResetCounters()
		{
			memset(ticks, 0, sizeof(LARGE_INTEGER)*256);
		}
		static inline float GetTime(int id)
		{
			QueryPerformanceFrequency(&freq);
			return ticks[id].QuadPart/(float)freq.QuadPart;
		}
	};
}

#endif